<?php
/**
 * @link http://cn2.php.net/manual/en/migration54.incompatible.php
 * @version $Id: 7_string_offset.php 211 2012-03-02 10:56:14Z horseluke@126.com $
 */

/*
7. Non-numeric string offsets - e.g. $a['foo'] where $a is a string - now
return false on isset() and true on empty(), and produce a warning if you 
try to use them. Offsets of types double, bool and null produce a notice. 
Numeric strings (e.g. $a['2']) still work as before. Note that offsets like
 '12.3' and '5 foobar' are considered non-numeric and produce a warning, but
  are converted to 12 and 5 respectively, for backward compatibility reasons.

备注：
测不出“Offsets of types double, bool and null produce a notice”，求补充

PHP 5.3 / PHP 5.2:
parse 1:
bool(true)

parse 2:
bool(false)

parse 3:
1
parse 4:
12.3 foobar

PHP 5.4:
parse 1:
bool(false)

parse 2:
bool(true)

parse 3:

Warning: Illegal string offset 'foo' in D:\htdoc_custom\php_5_4\7_string_offset.
php on line 33
1
parse 4:
12.3 foobar

*/
error_reporting(E_ALL);

$a = '12.3 foobar';

echo "\r\nparse 1:\r\n";
var_dump(isset($a['foo']));

echo "\r\nparse 2:\r\n";
var_dump(empty($a['foo']));

echo "\r\nparse 3:\r\n";
echo $a['foo'];

echo "\r\nparse 4:\r\n";
echo $a;
